home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / kewlpo1a / frmconfi.frm (.txt) next >
Encoding:
Visual Basic Form  |  1999-10-21  |  8.2 KB  |  256 lines

  1. VERSION 5.00
  2. Begin VB.Form frmConfigurations 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Configurations"
  5.    ClientHeight    =   2610
  6.    ClientLeft      =   3150
  7.    ClientTop       =   1980
  8.    ClientWidth     =   2880
  9.    Icon            =   "frmConfigurations.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    ScaleHeight     =   2610
  14.    ScaleWidth      =   2880
  15.    StartUpPosition =   2  'CenterScreen
  16.    Begin VB.CommandButton cmdCancel 
  17.       Caption         =   "&Cancel"
  18.       Height          =   375
  19.       Left            =   1800
  20.       TabIndex        =   8
  21.       Top             =   2160
  22.       Width           =   855
  23.    End
  24.    Begin VB.CommandButton cmdDefault 
  25.       Caption         =   "&Default"
  26.       Height          =   255
  27.       Left            =   2040
  28.       TabIndex        =   7
  29.       Top             =   0
  30.       Width           =   855
  31.    End
  32.    Begin VB.CommandButton cmdOK 
  33.       Caption         =   "&OK"
  34.       Default         =   -1  'True
  35.       Height          =   375
  36.       Left            =   240
  37.       TabIndex        =   2
  38.       Top             =   2160
  39.       Width           =   855
  40.    End
  41.    Begin VB.Frame fraPlayer2 
  42.       Caption         =   "Player 2"
  43.       BeginProperty Font 
  44.          Name            =   "MS Sans Serif"
  45.          Size            =   8.25
  46.          Charset         =   0
  47.          Weight          =   700
  48.          Underline       =   0   'False
  49.          Italic          =   0   'False
  50.          Strikethrough   =   0   'False
  51.       EndProperty
  52.       Height          =   855
  53.       Left            =   60
  54.       TabIndex        =   1
  55.       Top             =   1200
  56.       Width           =   2715
  57.       Begin VB.CommandButton cmdPlay2 
  58.          Caption         =   "Right Arrow"
  59.          Height          =   255
  60.          Index           =   1
  61.          Left            =   1200
  62.          TabIndex        =   12
  63.          Tag             =   "39"
  64.          Top             =   480
  65.          Width           =   1225
  66.       End
  67.       Begin VB.CommandButton cmdPlay2 
  68.          Caption         =   "Left Arrow"
  69.          Height          =   255
  70.          Index           =   0
  71.          Left            =   1200
  72.          TabIndex        =   11
  73.          Tag             =   "37"
  74.          Top             =   240
  75.          Width           =   1225
  76.       End
  77.       Begin VB.Label lblInfo 
  78.          Caption         =   "Move right:"
  79.          Height          =   255
  80.          Index           =   7
  81.          Left            =   240
  82.          TabIndex        =   10
  83.          Top             =   480
  84.          Width           =   1005
  85.       End
  86.       Begin VB.Label lblInfo 
  87.          Caption         =   "Move left:"
  88.          Height          =   375
  89.          Index           =   6
  90.          Left            =   240
  91.          TabIndex        =   9
  92.          Top             =   240
  93.          Width           =   1005
  94.       End
  95.    End
  96.    Begin VB.Frame fraPlayer1 
  97.       Caption         =   "Player 1"
  98.       BeginProperty Font 
  99.          Name            =   "MS Sans Serif"
  100.          Size            =   8.25
  101.          Charset         =   0
  102.          Weight          =   700
  103.          Underline       =   0   'False
  104.          Italic          =   0   'False
  105.          Strikethrough   =   0   'False
  106.       EndProperty
  107.       Height          =   975
  108.       Left            =   60
  109.       TabIndex        =   0
  110.       Top             =   120
  111.       Width           =   2715
  112.       Begin VB.CommandButton cmdPlay1 
  113.          Caption         =   ">"
  114.          Height          =   255
  115.          Index           =   1
  116.          Left            =   1200
  117.          TabIndex        =   6
  118.          Tag             =   "190"
  119.          Top             =   600
  120.          Width           =   1225
  121.       End
  122.       Begin VB.CommandButton cmdPlay1 
  123.          Caption         =   "<"
  124.          Height          =   255
  125.          Index           =   0
  126.          Left            =   1200
  127.          TabIndex        =   5
  128.          Tag             =   "188"
  129.          Top             =   360
  130.          Width           =   1225
  131.       End
  132.       Begin VB.Label lblInfo 
  133.          Caption         =   "Move right:"
  134.          Height          =   255
  135.          Index           =   1
  136.          Left            =   240
  137.          TabIndex        =   4
  138.          Top             =   600
  139.          Width           =   1005
  140.       End
  141.       Begin VB.Label lblInfo 
  142.          Caption         =   "Move left:"
  143.          Height          =   375
  144.          Index           =   0
  145.          Left            =   240
  146.          TabIndex        =   3
  147.          Top             =   360
  148.          Width           =   1000
  149.       End
  150.    End
  151. Attribute VB_Name = "frmConfigurations"
  152. Attribute VB_GlobalNameSpace = False
  153. Attribute VB_Creatable = False
  154. Attribute VB_PredeclaredId = True
  155. Attribute VB_Exposed = False
  156. Dim PlayNum As Byte
  157. Dim KeyArrayNum As Byte
  158. Public Sub GetKey(KeyCode As Integer)
  159.     Dim okQ As Boolean
  160.     okQ = True
  161.     For i = 0 To 1
  162.         If PlayNum <> 1 Or KeyArrayNum <> i Then
  163.             If KeyCode = cmdPlay1(i).Tag Then okQ = False
  164.         End If
  165.         If PlayNum <> 2 Or KeyArrayNum <> i Then
  166.             If KeyCode = cmdPlay2(i).Tag Then okQ = False
  167.         End If
  168.     Next i
  169.     If okQ Then
  170.         If PlayNum = 1 Then
  171.             With cmdPlay1(KeyArrayNum)
  172.                 .Tag = KeyCode
  173.                 .Caption = KeyStr(KeyCode)
  174.             End With
  175.         Else
  176.             With cmdPlay2(KeyArrayNum)
  177.                 .Tag = KeyCode
  178.                 .Caption = KeyStr(KeyCode)
  179.             End With
  180.         End If
  181.     Else
  182.         MsgBox "Sorry, but this key has already been taken!", vbExclamation + vbSystemModal, "Key already taken"
  183.     End If
  184. End Sub
  185. Private Sub cmdCancel_Click()
  186.     Unload Me
  187. End Sub
  188. Private Sub cmdDefault_Click()
  189.     If MsgBox("Are you sure you want to restore the key default settings?", vbQuestion + vbYesNo, "Restore defaults?") = vbYes Then
  190.         cmdPlay1(0).Caption = "<"
  191.         cmdPlay1(1).Caption = ">"
  192.         cmdPlay1(0).Tag = 188
  193.         cmdPlay1(1).Tag = 190
  194.         cmdPlay2(0).Caption = "Left Arrow"
  195.         cmdPlay2(1).Caption = "Right Arrow"
  196.         cmdPlay2(0).Tag = 37
  197.         cmdPlay2(1).Tag = 39
  198.     End If
  199. End Sub
  200. Private Sub cmdOK_Click()
  201.     On Error GoTo errdo
  202.     Dim fn As Integer
  203.     Dim SaveKeys As KeyFile
  204.     If MsgBox("Do you really wish to save your settings?", vbQuestion + vbYesNo, "Save settings?") = vbNo Then Exit Sub
  205.     fn = FreeFile
  206.     Open "keys.conf" For Random As #fn Len = Len(SaveKeys)
  207.         For i = 0 To 1
  208.             SaveKeys.Player1Key(i) = cmdPlay1(i).Caption
  209.             SaveKeys.Player1KeyTag(i) = cmdPlay1(i).Tag
  210.             SaveKeys.Player2Key(i) = cmdPlay2(i).Caption
  211.             SaveKeys.Player2KeyTag(i) = cmdPlay2(i).Tag
  212.         Next i
  213.         SaveKeys.FileType = "Pong Keyboard Configurations"
  214.         SaveKeys.Credits = "By " & MyName
  215.         Put #fn, 1, SaveKeys
  216.     Close
  217.     For i = 0 To 1
  218.         KeyCode1(i) = cmdPlay1(i).Tag
  219.         KeyCode2(i) = cmdPlay2(i).Tag
  220.         KeyStr1(i) = cmdPlay1(i).Caption
  221.         KeyStr2(i) = cmdPlay2(i).Caption
  222.     Next i
  223.     MsgBox "Configurations saved successfully!", vbExclamation, "Successful!"
  224.     Unload Me
  225.     Exit Sub
  226. errdo:
  227.     MsgBox "Unable to write to file!" & vbCrLf & "Settings still saved to be used in program.", vbCritical
  228.     For i = 0 To 5
  229.         KeyCode1(i) = cmdPlay1(i).Tag
  230.         KeyCode2(i) = cmdPlay2(i).Tag
  231.         KeyStr1(i) = cmdPlay1(i).Caption
  232.         KeyStr2(i) = cmdPlay2(i).Caption
  233.     Next i
  234.     Unload Me
  235. End Sub
  236. Private Sub cmdPlay1_Click(Index As Integer)
  237.     PlayNum = 1
  238.     KeyArrayNum = Index
  239.     frmNewKey.lblKeyName.Caption = "P1 " & lblInfo(Index).Caption
  240.     frmNewKey.Show 1
  241. End Sub
  242. Private Sub cmdPlay2_Click(Index As Integer)
  243.     PlayNum = 2
  244.     KeyArrayNum = Index
  245.     frmNewKey.lblKeyName.Caption = "P2 " & lblInfo(Index + 6).Caption
  246.     frmNewKey.Show 1
  247. End Sub
  248. Private Sub Form_Load()
  249.         For i = 0 To 1
  250.             cmdPlay1(i).Caption = KeyStr1(i)
  251.             cmdPlay1(i).Tag = KeyCode1(i)
  252.             cmdPlay2(i).Caption = KeyStr2(i)
  253.             cmdPlay2(i).Tag = KeyCode2(i)
  254.         Next i
  255. End Sub
  256.